
import Mock from 'mockjs'; 

function getMachinesList(options) {
  const { pageSize, page } =  options.query
  const result = Mock.mock({
    status: 'ok',
    'result|10': [
      {
        'id|1-100': 1,
        'name': "@ctitle(5,10)",
        'address': "@ctitle(10,20)",
        'status|0-2': 1,
        'tradeCount|50-500': 1,
      }
    ],
    pagination: {
      total: 100,
      page: page ? Number(page) : 1,
      pageSize:  pageSize ? Number(pageSize) : 20,
    }
  })
  return result
}


function getMachinesListByStatus(options) {
  const { pageSize, page, status } =  options.query
  const result = Mock.mock({
    status: 'ok',
    'result|10': [
      {
        'id|1-100': 1,
        'name': "@ctitle(5,10)",
        'address': "@ctitle(10,20)",
        status: Number(status),
        'tradeCount|50-500': 1,
      }
    ],
    pagination: {
      total: 100,
      page: page ? Number(page) : 1,
      pageSize:  pageSize ? Number(pageSize) : 20,
    }
  })
  return result
}

function getIncome() {
  const result = Mock.mock({
    status: 'ok',
    result: {
      'income|100-500': 1,
      'incomeCount|100-500': 1,
    }
  })
  return result
}




export default [
  {
    url: '/api/machines',
    method: 'get',
    response: getMachinesList,
  },
  {
    url: '/api/machines/status',
    method: 'get',
    response: getMachinesListByStatus,
  },
  {
    url: '/api/income',
    method: 'get',
    response: getIncome,
  },
];



